package com.example.firstservice;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button start =findViewById(R.id.start);
        start.setOnClickListener(new startListener());
        Button stop=findViewById(R.id.stop);
        stop.setOnClickListener(new stopListener());
        System.out.print("Activity onCreate");
    }
    class startListener implements View.OnClickListener{

        @Override
        public void onClick(View v) {
            Intent intent=new Intent();
            intent.setClass(MainActivity.this,firstservice.class);
            startService(intent);
        }
    }
    class stopListener implements View.OnClickListener{

        @Override
        public void onClick(View v) {
            Intent intent =new Intent();
            intent.setClass(MainActivity.this ,firstservice.class);
            stopService(intent);
        }
    }
}
